package cn.anxingongyou.anxin.service.impl;

import cn.anxingongyou.anxin.entity.WorkerExpenditure;
import cn.anxingongyou.anxin.mapper.WorkerExpenditureMapper;
import cn.anxingongyou.anxin.service.WorkerExpenditureService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WorkerExpenditureServiceImpl implements WorkerExpenditureService {

    private final WorkerExpenditureMapper workerExpenditureMapper;
    @Autowired
    public WorkerExpenditureServiceImpl(WorkerExpenditureMapper workerExpenditureMapper) {
        this.workerExpenditureMapper = workerExpenditureMapper;
    }

    @Override
    public int insert(WorkerExpenditure workerExpenditure) {
        return workerExpenditureMapper.insert(workerExpenditure);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return workerExpenditureMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(WorkerExpenditure workerExpenditure) {
        return workerExpenditureMapper.updateByPrimaryKeySelective(workerExpenditure);
    }

    @Override
    public WorkerExpenditure selectOne(WorkerExpenditure workerExpenditure) {
        return workerExpenditureMapper.selectOne(workerExpenditure);
    }

    @Override
    public WorkerExpenditure selectOneByPrimaryKey(Long id) {
        return workerExpenditureMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<WorkerExpenditure> page(int pageNum, int pageSize, WorkerExpenditure workerExpenditure) {
        String orderBy = "id desc";
        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(pageNum,pageSize,orderBy);
        List<WorkerExpenditure> list = workerExpenditureMapper.select(workerExpenditure);
        PageInfo<WorkerExpenditure> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
